package com.flybear.aqi.client;

import java.util.Map;

/**
 * Interface for an ElasticSearch client which is responsible for sending bulks
 * of events to ElasticSearch.
 */
public interface ElasticSearchClient  {
  public static final String BULKACTIONS = "bulkActions";
  public static final String FLUSHINTERVAL = "flushInterval";
  public static final String CONCURRENTREQUESTS = "concurrentRequests";
  public static final String BULKSIZE = "bulkSize";
  /**
   * Close connection to elastic search in client
   */
  void close();

  /**
   * Add new event to the bulk
   *
   * @param event
   *    Flume Event
   * @param indexName
   *    Index name builder which generates name of index to feed
   * @param indexType
   *    Name of type of document which will be sent to the elasticsearch cluster
   * @param ttlMs
   *    Time to live expressed in milliseconds. Value <= 0 is ignored
   * @throws Exception
   */
  public void addEvent(Map event, String indexName,
                       String indexType, long ttlMs) throws Exception;

  /**
   * Sends bulk to the elasticsearch cluster
   *
   * @throws Exception
   */
  void execute() throws Exception;
  void configure(Map<String, String> properties, Map<String, Object> conf);
}
